/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * Description:
 * Author: huawei
 * Create: 2019-10-15
 */

#ifndef _UDA_H
#define _UDA_H

#include <linux/device.h>

/****************************** chip type *********************************/
#define HISI_MINI_V1        0
#define HISI_CLOUD_V1       1
#define HISI_MINI_V2        2
#define HISI_CLOUD_V2       3
#define HISI_MINI_V3        4
#define HISI_CHIP_NUM       5
#define HISI_CHIP_UNKNOWN   6

enum uda_dev_hw {
    UDA_DAVINCI,
    UDA_KUNPENG,
    UDA_HW_MAX
};

enum uda_dev_object {
    UDA_ENTITY,
    UDA_AGENT,
    UDA_OBJECT_MAX
};

enum uda_dev_location {
    UDA_LOCAL,
    UDA_NEAR,
    UDA_REMOTE,
    UDA_LOCATION_MAX
};

enum uda_dev_prop {
    UDA_REAL,
    UDA_VIRTUAL,
    UDA_REAL_SEC_EH,
    UDA_PROP_MAX
};

struct uda_dev_type {
    enum uda_dev_hw hw;
    enum uda_dev_object object;
    enum uda_dev_location location;
    enum uda_dev_prop prop;
};

#define UDA_INVALID_UDEVID 0xffffffff

struct uda_dev_para {
    u32 udevid;
    u32 remote_udevid;
    u32 chip_type;
    struct device *dev;
};

enum uda_dev_ctrl_cmd {
    UDA_CTRL_SUSPEND,
    UDA_CTRL_RESUME,
    UDA_CTRL_TO_MIA,
    UDA_CTRL_TO_SIA,
    UDA_CTRL_MIA_CHANGE,
    UDA_CTRL_REMOVE,
    UDA_CTRL_MAX
};

int uda_add_dev(struct uda_dev_type *type, struct uda_dev_para *para, u32 *udevid);
int uda_remove_dev(struct uda_dev_type *type, u32 udevid);
int uda_set_detected_phy_dev_num(u32 dev_num);
/* only support physical device which udevid < 100 */
int uda_set_chip_type(u32 udevid, u32 chip_type);
u32 uda_get_chip_type(u32 udevid);
int uda_dev_ctrl(u32 udevid, enum uda_dev_ctrl_cmd cmd);
#endif